package com.twu.biblioteca.ui.menus;

import com.twu.biblioteca.BibliotecaApp;
import com.twu.biblioteca.app.Library;
import com.twu.biblioteca.app.user.User;

import java.io.BufferedReader;
import java.io.IOException;

public class ItemListMenu {
    private BufferedReader bufferedReader;

    public ItemListMenu(BufferedReader bufferedReader) {
        this.bufferedReader = bufferedReader;
    }

    public void displaySelectionError() {
        System.out.print("That item is not available.\n");
    }

    public Library readAndHandleMenuSelection(Library library, User user) {
        try {
            String input = this.bufferedReader.readLine();
            int selection = Integer.parseInt(input);
            library = this.attemptToCheckoutItem(selection, library, user);
        } catch (NumberFormatException nfe) {
            displaySelectionError();
        } catch (IOException e) {
            System.out.println("There was an error reading from the provided input reader.");
            BibliotecaApp.exit();
        }
        return library;
    }

    public Library attemptToCheckoutItem(int selection, Library library, User user) {
        return null;
    }

    public String getMenuOptions(Library library) {
        return null;
    }
}
